#include<bits/stdc++.h>
using namespace std;

const int Maxn = 1e5 + 5;
const int Maxm = 3e3 + 5;

long long n,m,L,V;
long long d[Maxn],v[Maxn],a[Maxn];
long long p[Maxn];
long long tong[Maxn];
long long l[Maxm][Maxm];

inline void read(long long &x)
{
    x = 0; int f = 1;
    char ch = getchar();
    while(!isdigit(ch)) f = ch == '-' ? -1 : f , ch = getchar();
    while( isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48) , ch = getchar();
    x *= f;
}

bool check()
{
    for (int i = 1; i <= n; ++i)
        if(a[i] < 0) return false;
    return true;
}

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    long long T;
    read(T);
    while(T--)
    {
        memset(l , 0 ,sizeof(l));
        memset(tong , 0 , sizeof(tong));
        read(n),read(m),read(L),read(V);
        V *= V;
        for (int i = 1; i <= n; ++i)
            read(d[i]),read(v[i]),read(a[i]),v[i] *= v[i];
        for (int i = 1; i <= m; ++i)
        {
            read(p[i]);
            for (int j = 1; j <= n; ++j)
            {
                if(d[j] > p[i]) continue;
                int dis = p[i] - d[j];
                int u = v[j] + 2 * a[j] * dis;
                if(u > V) tong[j]++ , l[i][++l[i][0]] = j;
            }
        }
        long long cnt = 0 , ans = 0;
        if(check())
        {
            sort(p + 1 , p + 1 + m);
            for (int i = 1; i <= n; ++i)
            {
                if(p[n] < d[i]) continue;
                int dis = p[n] - d[i];
                int u = v[i] + 2 * a[i] * dis;
                if(u > V) cnt++;
            }
            cout << cnt << " " << (cnt > 0) <<endl;
            continue;
        }
        for (int i = 1; i <= n; ++i)
            if(tong[i]) cnt++;
        for (int i = 1; i <= m; ++i)
        {
            bool flag = true;
            for (int j = 1; j <= l[i][0]; ++j)
            {
                if(tong[l[i][j]] == 1)
                {
                    flag = false;
                    break;
                }
            }
            if(flag)
            {
                ans++;
                for (int j = 1; j <= l[i][0]; ++j)
                    tong[l[i][j]]--;
            }
        }
        cout << cnt << " " << ans <<endl;
    }
    return 0;
}
